# coding=utf-8
from socketserver import ThreadingMixIn
from xmlrpc.server import SimpleXMLRPCServer
from hostServerCode import host_manager, container_manager

PORT = 8001


class RPCThreading(ThreadingMixIn, SimpleXMLRPCServer):
    pass

RpcThreadClass = RPCThreading(('', int(PORT)), allow_none=True)
RpcThreadClass.register_function(host_manager.updateHostStatus)
RpcThreadClass.register_function(host_manager.getAllImages)
RpcThreadClass.register_function(host_manager.getNodeInfomation)
RpcThreadClass.register_function(host_manager.importImages)
RpcThreadClass.register_function(host_manager.dockerPullImage)
RpcThreadClass.register_function(host_manager.deleteImage)
RpcThreadClass.register_function(host_manager.createLocalImage)
RpcThreadClass.register_function(container_manager.getAllContainers)
RpcThreadClass.register_function(container_manager.stopContainer)
RpcThreadClass.register_function(container_manager.start_Container)
RpcThreadClass.register_function(container_manager.delete_Container)
RpcThreadClass.register_function(container_manager.create_Container)


def startRun():
    RpcThreadClass.serve_forever()

